package model;

import java.io.File;

/*
表示一个用户
 */
public class User {
    private int userId = 0;
    private String userName = "";
    private String password = "";
    private String photo = "";
    private String github = null;
    private int count;// 作品数量

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public String getGithub() {
        return github;
    }

    public void setGithub(String github) {
        this.github = github;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public static void deletePhoto(String username){
        File rootDir = new File("E:/gitee_program/java-ee-elementary/blog_system/src/main/webapp/image/");
        File[] list = rootDir.listFiles();
        for (File fi : list) {
            String fileName = fi.getName().split("_")[0];
            if (fileName.equals(username)){
                fi.delete();
                break;
            }
        }
    }
}
